package com.chenjj.java.business.order;

import java.io.Serializable;
import java.util.Comparator;
import java.util.Date;

public class OrderInfoVO implements Serializable {
    /**
     * 订单号
     */
    private String orderNum;

    /**
     * 交易时间
     */
    private Date orderTime;

    /**
     * 交易金额
     */
    private double money;

    public String getOrderNum() {
        return orderNum;
    }

    public void setOrderNum(String orderNum) {
        this.orderNum = orderNum;
    }

    public Date getOrderTime() {
        return orderTime;
    }

    public void setOrderTime(Date orderTime) {
        this.orderTime = orderTime;
    }

    public double getMoney() {
        return money;
    }

    public void setMoney(double money) {
        this.money = money;
    }


    //成员变量修饰符 --- start
    protected double v_protected;

    public  double v_public;

    private  double v_private;

    double v_default;

    protected void m_protected(){}

    public void m_public(){}

    private void m_private(){}

    void m_default(){}

    public class c_public{}

    private class c_private{}

    protected class c_protected{}

    class c_default{}

    //成员变量修饰符 --- end


    /**
     * =====================================
     *
     * Comparator升序/降序逻辑
     *
     * 降序: o1 < o2 = true , return 1  ；&&  o1< o2  =false, return -1
     * 升序: o1 < o2 = true , return -1;  &&   o1< o2 =false, return 1
     *
     * =====================================
     */


    /**
     * 根据金额排序
     */
    public static class OrderComparator implements Comparator<OrderInfoVO>{

        /**
         *
         * @param o1
         * @param o2
         * @return
         */
        @Override
        public int compare(OrderInfoVO o1, OrderInfoVO o2) {
            int ret = 0;
            //System.out.println(o1.getMoney()+" vs " + o2.getMoney());
            try{
                double d = o1.getMoney() - o2.getMoney();
                if(d>0){ //o1 < o2 = false
                    ret = 1;
                }else if (d < 0){ // o1 < o2 = true
                    ret = -1;
                }else{
                    ret = 0;
                }

            }catch (Exception e){
                e.printStackTrace();
                ret = 0;
            }
            return ret;
        }
    }


    /**
     * 根据订单号排序
     */
    public static class OrderComparator1 implements Comparator<OrderInfoVO>{
        @Override
        public int compare(OrderInfoVO o1, OrderInfoVO o2) {

            return 0;
        }
    }
}
